Python Labs

Monte Carlo

Kannan Singaravelu
kannan.singaravelu@fitchlearning.com

Monte Carlo Approach

Monte Carlo methods are any process that consumes random numbers. These are part of computational algorithms which are based on random sampling to obtain numerical results. Monte Carlo methods are proved to be a very valuable and flexible computational tool in finance and is one of the most widely used methods for optimization and numerical integration problems.

These methods are widely used in high dimensional problems; pricing exotics and complex derivatives where closed form solutions are not directly available. Monte Carlo methods are not just adapted in pricing complex derivatives, It is also extensively used in estimating the portfolio risk such as Value-at-Risk and Expected Shortfall and used in the calculation of worst-case scenarios in stress testing. The downside to that is, it is very computational intensive and demanding.

Monte Carlo Simulation

A method of estimating the value of an unknown quantity using the principles of inferential statistics.

We take the population and then we sample it by drawing a proper subset. And then we make an inference about the population based upon some set of statistics we do on the sample.

And, the key fact that makes them work, that if we choose the sample at random, the sample will tend to exhibit the same properties as the population from which it is drawn.

Option Pricing Techniques

As with other option pricing techniques Monte Carlo methods are used to price options using what is essentially a three step process.

Step 1: Simulate potential price paths of the underlying asset.
Step 2: Calculate the option payoff for each of these price paths.
Step 3: Average the payoff and discount back to today to determine the option price.

Simulating Asset Prices

Next, we will simulate the asset price at maturity $S_{T}$. Following Black-Scholes-Merton where the underlying follows under risk neutrality, a geometric Brownian motion with a stochastic differential equation (SDE) is given as

\begin{equation*} dS_{t} = rS_{t}dt + σS_{t}dZ_{t} \end{equation*}

where $S_{t}$ is the price of the underlying at time $t$, σ is constant volatility, $r$ is the constant risk-free interest rate and $Z$ is the brownian motion.

Applying Euler discretization of SDE, we get

\begin{equation*} S_{t} = S_{t-{\Delta}t} exp^{((r-\frac{1}2{\sigma}^2){\Delta}t +{\sigma}{\sqrt{\Delta}t}z{t})} \end{equation*}

The variable z is a standard normally distributed random variable, 0 < ${\Delta}$t < T, time interval. It also holds 0 < t ≤ T with T the final time horizon.

Import Required Libraries

Generate Price Paths

Simulating price paths plays an important role in the valuation of derivatives and it is always prudent to create a separate path function.

Numpy Vectorization

One of the two major benefits of using Numpy is

a) Syntax: compact, vectorized syntax allowing for even 100,000 calculations within a single line of code.
b) Speed: faster as majority of the code is implemented in C.

Assume, we have a vector with the first 100 natural numbers 1,2, 3,...100

$$ \vec v = \begin{pmatrix} 1 \\ 2 \\ . \\ . \\ . \\ 100 \end{pmatrix} $$

then, the scalar multiplication of this vector is written compactly as:

$$ \vec u = 2 \cdot \vec v = \begin{pmatrix} 2 \\ 4 \\ . \\ . \\ . \\ 200 \end{pmatrix} $$

Let's see this with an example

User Defined Function

Histogram of Psuedo Random Numbers

Histogram of Simulated Paths

Visualization of Simulated Paths

Variance Reduction

Monte Carlo methods are simulation algorithms to estimate a numerical quantity in a statistical model. There are few methods that provide for high accurary. Variance reduction techniques such as a) antithetic variates, b) control variates and c) moment matching are widely adopted.

In antithetic variates, we try to reduce the variance by introducing negative dependence between pairs of random draws while in moment matching, we correct the set of standard normal pseudo-random numbers generated by Python to match the first two moments correctly. In control variates method, we exploit information about the errors in estimates of known quantities to reduce the error of an estimate of an unknown quantity.

Do pseudorandom numbers exhibit desired properties?

Python functions generate pseudorandom numbers that might exhibit the expected statistical behaviour. We try to achieve the desired property by employing variance reduction techniques.

Without Antithetic Variates
With Antithetic Variates

Risk-Neutral Valuation

A call option gives the holder of the option the right to buy the asset at a pre-defined price. A call buyer makes money if the price of the asset at maturity, denoted by $S_{T}$, is above the strike price $K$, otherwise it's worth nothing.

\begin{equation*} C_{T} = max (0, S_{T} - K) \end{equation*}

The price of an option using a Monte Carlo simulation is the expected value of its future payoff. So at any date before maturity, denoted by $t$, the option's value is the present value of the expectation of its payoff at maturity, $T$.

\begin{equation*} C = PV(E[max (0,S_{T}-K)]) \end{equation*}

Under the risk-neutral framework, we assume the asset is going to earn, on average, the risk-free interest rate. Hence, the option value at time $t$ would simply be the discounted value of the expected payoff.

\begin{equation*} C = e^{−r(T−t)}(E[max (0,S_{T}-K)]) \end{equation*}

European Option

To price an option, we generate many possible price paths that the asset might take at maturity and then calculate option payoffs for each of those generated prices, average them to get the expected payoff and then discount it at risk free to arrive at the final value.

Given that Monte Carlo algorithms are computationaly heavy, it is necessary to implement efficiently. We'll use vectorization with NumPy for effective algorithm as NumPy syntax are more compact and are faster.

Visualization of Option Payoff

References

< QuantLib-Python | Contents | Finite Difference >